package com.jstide.credit.data.service.biz;

import cn.hutool.core.util.StrUtil;
import cn.hutool.db.Entity;
import com.jstide.credit.data.service.Algorithm;
import lombok.Getter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.ResultSet;
import java.sql.Struct;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Factor21 extends Algorithm {

    private static final Logger logger = LoggerFactory.getLogger(Factor21.class);

    @Getter
    public final  String name="21";

    //表彰信息（100分）“国、部”100分；“厅、省”70分；“市”50分
    // 取最高等级，计数1次
    //100
    @Getter
    public  final String sql ="   select RDBMQC from  ZRRBZXX where join_id=@joinId   ";

    @Override
    public int translate(String rs) {
        return 0;
    }


    @Override
    public int translate(List<Entity> rs) {
        int score = 0;
        if(null!=rs && rs.size()>0){
            score = rs.stream().filter(t-> StrUtil.containsAny(t.getStr("RDBMQC"),"国","部")).count()>0 ? 100:0;
            if(score==0){
                score =  rs.stream().filter(t->StrUtil.containsAny(t.getStr("RDBMQC"),"厅","省")).count() >0 ?70:0;
            }
            if(score==0){
                score = rs.stream().filter(t-> StrUtil.containsAny(t.getStr("RDBMQC"),"市")).count()>0? 50:0;
            }
        }
        return score;
    }
}
